package P1000;

import java.util.Scanner;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-10-08 11:17
 */
public class P1047_校门外的树 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int L = scanner.nextInt();
        int nums = scanner.nextInt();
        boolean[] flags = new boolean[L+1];
        int res = L+1;
        while(nums-- > 0){
            int left = scanner.nextInt();
            int right = scanner.nextInt();
            for(int i=left;i<=right;++i){
                if(!flags[i]){
                    flags[i] = true;
                    --res;
                }
            }
        }
        scanner.close();
        System.out.println(res);
    }
}
